<template>
	<view class="yue-container">
		<view class="padding">
			<view class="header flexbetween">
				<view class="">
					<view class="count">账户余额(元)</view>
					<view class="name">{{totalMoney}}</view>
				</view>
				<view class="margin-top">
					<view class="tixian" @click="tixian">提现</view>
				</view>
			</view>
			<view class="">
				<view class="title">余额明细</view>
				<view class="shadow"></view>
			</view>
			<!-- 空白页 -->
			<view class="zwtimg placeholderimg flexcenter" v-if="moneyInfoList.data.length==0">
							<image src="@/static/image/bg-icons/placeholderimg.png" mode=""></image>
						</view>
			<!-- 明细： -->
			<view class="yue_list" v-else>
				<view class="yue_list_a flexbetween" v-for="item in moneyInfoList.data" :key="item.id">
					<view class="line_one">
						<view class="word">{{item.memo}}</view>
						<text class="line_two">{{item.createtime_text}}</text>
					</view>
					<view class=" money">{{item.money}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				totalMoney: "",
				page: 1,
				limit: 12,
				moneyInfoList: {
					data: []
				}
			};
		},
		onShow() {
			this.getUserInfo()
			this.getMoneyInfo()
		},
		methods: {
			tixian() {
				uni.navigateTo({
					url: '/pages_my/tixian'
				})
			},
			getUserInfo() { //余额
				let _this = this
				httpRequest.request('/api/user/index', 'GET', {

				}).then(res => {
					if (res.code == 1) {
						_this.totalMoney = res.data.money
					} else if (res.code == 0) {
						httpRequest.toast(res.msg);
					} else {
						httpRequest.toast('网络开小差啦');
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			getMoneyInfo(isPage, page) { //余额明细
				let _this = this
				httpRequest.request('/api/user/getUserMoneyLog', 'GET', {
					page: page || 1,
					limit: _this.limit
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.moneyInfoList;
						if (isPage == true) {
							_this.moneyInfoList.data = dataList.data.concat(resList.data);
						} else {
							this.moneyInfoList = res.data
							_this.moneyInfoList.data = resList.data;
						}
					} else if (res.code == 0) {
						httpRequest.toast(res.msg);
					} else {
						httpRequest.toast('网络开小差啦');
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.moneyInfoList;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.getMoneyInfo(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.yue_list_a {
		border-bottom: 2rpx solid RGBA(247, 247, 247, 1);
		padding: 34rpx 27rpx 30rpx 37rpx;
	}

	.yue-container {
		box-sizing: border-box;
		background-color: #fafafa;
		min-height: 100vh;
	}

	.header {
		height: 164rpx;
		background-image: url('');
		background-size: 100% 100%;
		overflow: hidden;
		padding: 30rpx 40rpx;
	}

	.count {
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}

	.name {
		font-size: 38rpx;
		font-family: DIN-Bold, DIN;
		font-weight: bold;
		color: #FFFFFF;
		margin-top: 24rpx;
	}

	.chongzhi {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		margin-top: 30rpx;
		padding: 13rpx 69rpx;
		border: 1rpx solid #fff;
		border-radius: 10rpx;
		margin-right: 84rpx;
	}

	.tixian {
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		padding: 15rpx 48rpx;
		border: 1rpx solid #fff;
		border-radius: 10rpx;
		box-shadow: 0rpx 12rpx 12rpx 0rpx rgba(0, 0, 0, 0.05);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
	}

	.title {
		font-size: 32rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
		margin-top: 30rpx;
		//background: url("/static/image/my/jianbian.png") no-repeat;
		background-position: left bottom;
		background-size: 100%;
		box-sizing: border-box;
		display: inline-block;
	}

	.yue_list {
		background-color: #fff;
		margin-top: 30rpx;
		border-radius: 16rpx;
	}

	/* .yue_list_item {
		padding: 30rpx;
		border-bottom: 1rpx solid #fcfcfc;
	} */

	.yue_list_item:last-child {
		border-bottom: none;
	}


	.word {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #333333;
	}

	.money {
		font-size: 32rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: rgba(212, 139, 57, 1);
	}

	.line_two {
		margin-top: 11rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
</style>